/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.scalia.meteocal.entity;

import com.scalia.meteocal.control.PasswordEncrypter;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 *
 * @author gabriele
 */
@Entity(name = "EVENT")
@NamedQueries({
        @NamedQuery(name = Event.findAll, query = "SELECT e FROM EVENT e WHERE e.deleted = false"),
        @NamedQuery(name = Event.findAllOfUser, query = "SELECT e FROM EVENT e WHERE e.creator = :user and e.deleted = false"),
        @NamedQuery(name = Event.findAllPartecipationsOfUser, query = "SELECT e FROM EVENT e, INVITATION i WHERE i.event.id = e.id and i.user = :user and i.accepted = true and e.deleted = false"),
})
public class Event implements Serializable {

    private static final long serialVersionUID = 1L;
    public static final String findAll = "findAllEvents";
    public static final String findAllOfUser = "findAllEventsOfUser";
    public static final String findAllPartecipationsOfUser = "findAllPartecipationsOfUser";
    public static final int MIN_TEMPERATURE_AVAIABLE = -10;
    public static final int MAX_TEMPERATURE_AVAIABLE = 40;
    
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    
    @NotNull(message = Messages.NOT_EMPTY)
    private String name;
    
    @NotNull(message = Messages.NOT_EMPTY)
    private String place;
    
    @NotNull(message = Messages.NOT_EMPTY)
    private String address;
    
    @NotNull(message = Messages.NOT_EMPTY)
    private String country;
    
    @NotNull(message = Messages.NOT_EMPTY)
    private String city;

    @Temporal(TemporalType.TIMESTAMP)
    @NotNull(message = Messages.NOT_EMPTY)
    private Date startTime;
    
    @Temporal(TemporalType.TIMESTAMP)
    @NotNull(message = Messages.NOT_EMPTY)
    private Date endTime;
    
    @NotNull(message = Messages.NOT_EMPTY)
    private boolean outdoor;
    
    @NotNull(message = Messages.NOT_EMPTY)
    private boolean deleted;

    private Float minTemperature;

    private Float maxTemperature;
    
    private Float forecastTemperature;
        
    @NotNull(message = Messages.NOT_EMPTY)
    private boolean notificated;
    
    @NotNull(message = Messages.NOT_EMPTY)
    @ManyToOne
    @JoinColumn(referencedColumnName="USERNAME")
    private User creator;
    
    @Temporal(TemporalType.TIMESTAMP)
    @NotNull(message = Messages.NOT_EMPTY)
    private Date creationTimestamp;
    
    private String weatherTypeForecast;
    
    private String badWeatherTypes;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public boolean isOutdoor() {
        return outdoor;
    }

    public void setOutdoor(boolean outdoor) {
        this.outdoor = outdoor;
    }

    public Float getMinTemperature() {
        return minTemperature;
    }

    public void setMinTemperature(Float minTemperature) {
        this.minTemperature = minTemperature;
    }

    public Float getMaxTemperature() {
        return maxTemperature;
    }

    public void setMaxTemperature(Float maxTemperature) {
        this.maxTemperature = maxTemperature;
    }

    public Float getForecastTemperature() {
        return forecastTemperature;
    }

    public void setForecastTemperature(Float forecastTemperature) {
        this.forecastTemperature = forecastTemperature;
    }

    public boolean isNotificated() {
        return notificated;
    }

    public void setNotificated(boolean notificated) {
        this.notificated = notificated;
    }

    public User getCreator() {
        return creator;
    }

    public void setCreator(User creator) {
        this.creator = creator;
    }

    public Date getCreationTimestamp() {
        return creationTimestamp;
    }

    public void setCreationTimestamp(Date creationTimestamp) {
        this.creationTimestamp = creationTimestamp;
    }

    public String getWeatherTypeForecast() {
        return weatherTypeForecast;
    }

    public void setWeatherTypeForecast(String weatherTypeForecast) {
        this.weatherTypeForecast = weatherTypeForecast;
    }

    public String getBadWeatherTypes() {
        return badWeatherTypes;
    }

    public void setBadWeatherTypes(String badWeatherTypes) {
        this.badWeatherTypes = badWeatherTypes;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }
    
    
}
